package com.example.spring.receiver;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@RabbitListener(queues = "topic.messages")
public class TopicReceiver2 {

    /**
     * Topic Exchange 转发消息主要是根据通配符，队列topic.message只能匹配topic.message的路由。
     * 而topic.messages匹配路由规则是topic.#，所以它可以匹配topic.开头的全部路由。而topic.#发送的消息也只能是topic.#的接受者才能接收。
     *
     * @param msg
     */
    @RabbitHandler
    public void topicReceiver(String msg) {
        System.out.println("TopicReceiver2:" + msg);
    }

}
